//
// CPatch.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CRGBA;
import org.ryzom.nel.misc.CUV;
import org.ryzom.nel.misc.CVector;
import org.ryzom.nel.misc.IStream;

public class CPatch {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CPatch(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CPatch obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CPatch(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public void setVertices(CVector3s value) {
    nel3dJNI.CPatch_Vertices_set(swigCPtr, this, CVector3s.getCPtr(value), value);
  }

  public CVector3s getVertices() {
    long cPtr = nel3dJNI.CPatch_Vertices_get(swigCPtr, this);
    return (cPtr == 0) ? null : new CVector3s(cPtr, false);
  }

  public void setTangents(CVector3s value) {
    nel3dJNI.CPatch_Tangents_set(swigCPtr, this, CVector3s.getCPtr(value), value);
  }

  public CVector3s getTangents() {
    long cPtr = nel3dJNI.CPatch_Tangents_get(swigCPtr, this);
    return (cPtr == 0) ? null : new CVector3s(cPtr, false);
  }

  public void setInteriors(CVector3s value) {
    nel3dJNI.CPatch_Interiors_set(swigCPtr, this, CVector3s.getCPtr(value), value);
  }

  public CVector3s getInteriors() {
    long cPtr = nel3dJNI.CPatch_Interiors_get(swigCPtr, this);
    return (cPtr == 0) ? null : new CVector3s(cPtr, false);
  }

  public void setCompressedLumels(SWIGTYPE_p_std__vectorT_unsigned_char_t value) {
    nel3dJNI.CPatch_CompressedLumels_set(swigCPtr, this, SWIGTYPE_p_std__vectorT_unsigned_char_t.getCPtr(value));
  }

  public SWIGTYPE_p_std__vectorT_unsigned_char_t getCompressedLumels() {
    long cPtr = nel3dJNI.CPatch_CompressedLumels_get(swigCPtr, this);
    return (cPtr == 0) ? null : new SWIGTYPE_p_std__vectorT_unsigned_char_t(cPtr, false);
  }

  public void setTiles(SWIGTYPE_p_std__vectorT_CTileElement_t value) {
    nel3dJNI.CPatch_Tiles_set(swigCPtr, this, SWIGTYPE_p_std__vectorT_CTileElement_t.getCPtr(value));
  }

  public SWIGTYPE_p_std__vectorT_CTileElement_t getTiles() {
    long cPtr = nel3dJNI.CPatch_Tiles_get(swigCPtr, this);
    return (cPtr == 0) ? null : new SWIGTYPE_p_std__vectorT_CTileElement_t(cPtr, false);
  }

  public void setTileColors(SWIGTYPE_p_std__vectorT_CTileColor_t value) {
    nel3dJNI.CPatch_TileColors_set(swigCPtr, this, SWIGTYPE_p_std__vectorT_CTileColor_t.getCPtr(value));
  }

  public SWIGTYPE_p_std__vectorT_CTileColor_t getTileColors() {
    long cPtr = nel3dJNI.CPatch_TileColors_get(swigCPtr, this);
    return (cPtr == 0) ? null : new SWIGTYPE_p_std__vectorT_CTileColor_t(cPtr, false);
  }

  public void setTileLightInfluences(SWIGTYPE_p_std__vectorT_CTileLightInfluence_t value) {
    nel3dJNI.CPatch_TileLightInfluences_set(swigCPtr, this, SWIGTYPE_p_std__vectorT_CTileLightInfluence_t.getCPtr(value));
  }

  public SWIGTYPE_p_std__vectorT_CTileLightInfluence_t getTileLightInfluences() {
    long cPtr = nel3dJNI.CPatch_TileLightInfluences_get(swigCPtr, this);
    return (cPtr == 0) ? null : new SWIGTYPE_p_std__vectorT_CTileLightInfluence_t(cPtr, false);
  }

  public void setNoiseRotation(short value) {
    nel3dJNI.CPatch_NoiseRotation_set(swigCPtr, this, value);
  }

  public short getNoiseRotation() {
    return nel3dJNI.CPatch_NoiseRotation_get(swigCPtr, this);
  }

  public void setCornerSmoothFlag(long corner, boolean smooth) {
    nel3dJNI.CPatch_setCornerSmoothFlag(swigCPtr, this, corner, smooth);
  }

  public boolean getCornerSmoothFlag(long corner) {
    return nel3dJNI.CPatch_getCornerSmoothFlag(swigCPtr, this, corner);
  }

  public CPatch() {
    this(nel3dJNI.new_CPatch(), true);
  }

  public void compile(CZone z, long patchId, short orderS, short orderT, SWIGTYPE_p_p_CTessVertex baseVertices, float errorSize) {
    nel3dJNI.CPatch_compile__SWIG_0(swigCPtr, this, CZone.getCPtr(z), z, patchId, orderS, orderT, SWIGTYPE_p_p_CTessVertex.getCPtr(baseVertices), errorSize);
  }

  public void compile(CZone z, long patchId, short orderS, short orderT, SWIGTYPE_p_p_CTessVertex baseVertices) {
    nel3dJNI.CPatch_compile__SWIG_1(swigCPtr, this, CZone.getCPtr(z), z, patchId, orderS, orderT, SWIGTYPE_p_p_CTessVertex.getCPtr(baseVertices));
  }

  public void release() {
    nel3dJNI.CPatch_release(swigCPtr, this);
  }

  public CLandscape getLandscape() {
    long cPtr = nel3dJNI.CPatch_getLandscape(swigCPtr, this);
    return (cPtr == 0) ? null : new CLandscape(cPtr, false);
  }

  public CZone getZone() {
    long cPtr = nel3dJNI.CPatch_getZone(swigCPtr, this);
    return (cPtr == 0) ? null : new CZone(cPtr, false);
  }

  public short getOrderS() {
    return nel3dJNI.CPatch_getOrderS(swigCPtr, this);
  }

  public short getOrderT() {
    return nel3dJNI.CPatch_getOrderT(swigCPtr, this);
  }

  public short getOrderForEdge(char edge) {
    return nel3dJNI.CPatch_getOrderForEdge(swigCPtr, this, edge);
  }

  public float getErrorSize() {
    return nel3dJNI.CPatch_getErrorSize(swigCPtr, this);
  }

  public int getFar0() {
    return nel3dJNI.CPatch_getFar0(swigCPtr, this);
  }

  public int getFar1() {
    return nel3dJNI.CPatch_getFar1(swigCPtr, this);
  }

  public long getPatchId() {
    return nel3dJNI.CPatch_getPatchId(swigCPtr, this);
  }

  public void getBindNeighbor(long edge, SWIGTYPE_p_NL3D__CPatch__CBindInfo neighborEdge) {
    nel3dJNI.CPatch_getBindNeighbor(swigCPtr, this, edge, SWIGTYPE_p_NL3D__CPatch__CBindInfo.getCPtr(neighborEdge));
  }

  public SWIGTYPE_p_NLMISC__CAABBox buildBBox() {
    return new SWIGTYPE_p_NLMISC__CAABBox(nel3dJNI.CPatch_buildBBox(swigCPtr, this), true);
  }

  public CVector computeVertex(float s, float t) {
    return new CVector(nel3dJNI.CPatch_computeVertex(swigCPtr, this, s, t), true);
  }

  public CVector computeContinousVertex(float s, float t) {
    return new CVector(nel3dJNI.CPatch_computeContinousVertex(swigCPtr, this, s, t), true);
  }

  public void unbind() {
    nel3dJNI.CPatch_unbind(swigCPtr, this);
  }

  public void bind(SWIGTYPE_p_NL3D__CPatch__CBindInfo Edges, boolean rebind) {
    nel3dJNI.CPatch_bind(swigCPtr, this, SWIGTYPE_p_NL3D__CPatch__CBindInfo.getCPtr(Edges), rebind);
  }

  public void forceMergeAtTileLevel() {
    nel3dJNI.CPatch_forceMergeAtTileLevel(swigCPtr, this);
  }

  public void averageTesselationVertices() {
    nel3dJNI.CPatch_averageTesselationVertices(swigCPtr, this);
  }

  public void refineAll() {
    nel3dJNI.CPatch_refineAll(swigCPtr, this);
  }

  public void preRender(SWIGTYPE_p_NLMISC__CBSphere patchSphere) {
    nel3dJNI.CPatch_preRender(swigCPtr, this, SWIGTYPE_p_NLMISC__CBSphere.getCPtr(patchSphere));
  }

  public void updateTextureFarOnly(SWIGTYPE_p_NLMISC__CBSphere patchSphere) {
    nel3dJNI.CPatch_updateTextureFarOnly(swigCPtr, this, SWIGTYPE_p_NLMISC__CBSphere.getCPtr(patchSphere));
  }

  public void renderFar0() {
    nel3dJNI.CPatch_renderFar0(swigCPtr, this);
  }

  public void renderFar1() {
    nel3dJNI.CPatch_renderFar1(swigCPtr, this);
  }

  public void computeSoftwareGeomorphAndAlpha() {
    nel3dJNI.CPatch_computeSoftwareGeomorphAndAlpha(swigCPtr, this);
  }

  public void updateClipPatchVB(boolean renderClipped) {
    nel3dJNI.CPatch_updateClipPatchVB(swigCPtr, this, renderClipped);
  }

  public CPatch getNextFar0ToRdr() {
    long cPtr = nel3dJNI.CPatch_getNextFar0ToRdr(swigCPtr, this);
    return (cPtr == 0) ? null : new CPatch(cPtr, false);
  }

  public CPatch getNextFar1ToRdr() {
    long cPtr = nel3dJNI.CPatch_getNextFar1ToRdr(swigCPtr, this);
    return (cPtr == 0) ? null : new CPatch(cPtr, false);
  }

  public void resetRenderFar() {
    nel3dJNI.CPatch_resetRenderFar(swigCPtr, this);
  }

  public void deleteTileUvs() {
    nel3dJNI.CPatch_deleteTileUvs(swigCPtr, this);
  }

  public void recreateTileUvs() {
    nel3dJNI.CPatch_recreateTileUvs(swigCPtr, this);
  }

  public void refreshTesselationGeometry() {
    nel3dJNI.CPatch_refreshTesselationGeometry(swigCPtr, this);
  }

  public void serial(IStream f) {
    nel3dJNI.CPatch_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public void unpack(CBezierPatch p) {
    nel3dJNI.CPatch_unpack(swigCPtr, this, CBezierPatch.getCPtr(p), p);
  }

  public void unpackShadowMap(SWIGTYPE_p_unsigned_char pShadow) {
    nel3dJNI.CPatch_unpackShadowMap(swigCPtr, this, SWIGTYPE_p_unsigned_char.getCPtr(pShadow));
  }

  public void packShadowMap(SWIGTYPE_p_unsigned_char pLumel) {
    nel3dJNI.CPatch_packShadowMap(swigCPtr, this, SWIGTYPE_p_unsigned_char.getCPtr(pLumel));
  }

  public void resetCompressedLumels() {
    nel3dJNI.CPatch_resetCompressedLumels(swigCPtr, this);
  }

  public void setupColorsFromTileFlags(CRGBA colors) {
    nel3dJNI.CPatch_setupColorsFromTileFlags(swigCPtr, this, CRGBA.getCPtr(colors), colors);
  }

  public void copyTileFlagsFromPatch(CPatch src) {
    nel3dJNI.CPatch_copyTileFlagsFromPatch(swigCPtr, this, CPatch.getCPtr(src), src);
  }

  public long countNumTriFar0() {
    return nel3dJNI.CPatch_countNumTriFar0(swigCPtr, this);
  }

  public long countNumTriFar1() {
    return nel3dJNI.CPatch_countNumTriFar1(swigCPtr, this);
  }

  public void setSmoothFlag(long edge, boolean flag) {
    nel3dJNI.CPatch_setSmoothFlag(swigCPtr, this, edge, flag);
  }

  public boolean getSmoothFlag(long edge) {
    return nel3dJNI.CPatch_getSmoothFlag(swigCPtr, this, edge);
  }

  public void addTrianglesInBBox(CPatchIdent paId, SWIGTYPE_p_NLMISC__CAABBox bbox, SWIGTYPE_p_std__vectorT_NL3D__CTrianglePatch_t triangles, short tileTessLevel) {
    nel3dJNI.CPatch_addTrianglesInBBox(swigCPtr, this, CPatchIdent.getCPtr(paId), paId, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox), SWIGTYPE_p_std__vectorT_NL3D__CTrianglePatch_t.getCPtr(triangles), tileTessLevel);
  }

  public void fillPatchQuadBlock(CPatchQuadBlock quadBlock) {
    nel3dJNI.CPatch_fillPatchQuadBlock(swigCPtr, this, CPatchQuadBlock.getCPtr(quadBlock), quadBlock);
  }

  public void addPatchBlocksInBBox(CPatchIdent paId, SWIGTYPE_p_NLMISC__CAABBox bbox, SWIGTYPE_p_std__vectorT_NL3D__CPatchBlockIdent_t paBlockIds) {
    nel3dJNI.CPatch_addPatchBlocksInBBox(swigCPtr, this, CPatchIdent.getCPtr(paId), paId, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox), SWIGTYPE_p_std__vectorT_NL3D__CPatchBlockIdent_t.getCPtr(paBlockIds));
  }

  public CVector getTesselatedPos(CUV uv) {
    return new CVector(nel3dJNI.CPatch_getTesselatedPos(swigCPtr, this, CUV.getCPtr(uv), uv), true);
  }

  public void appendTessellationLeaves(SWIGTYPE_p_std__vectorT_CTessFace_const_p_t leaves) {
    nel3dJNI.CPatch_appendTessellationLeaves(swigCPtr, this, SWIGTYPE_p_std__vectorT_CTessFace_const_p_t.getCPtr(leaves));
  }

  public short getLumel(CUV uv) {
    return nel3dJNI.CPatch_getLumel(swigCPtr, this, CUV.getCPtr(uv), uv);
  }

  public void appendTileLightInfluences(CUV uv, SWIGTYPE_p_std__vectorT_CPointLightInfluence_t pointLightList) {
    nel3dJNI.CPatch_appendTileLightInfluences(swigCPtr, this, CUV.getCPtr(uv), uv, SWIGTYPE_p_std__vectorT_CPointLightInfluence_t.getCPtr(pointLightList));
  }

  public void computeCurrentTLILightmapDiv2(CRGBA array) {
    nel3dJNI.CPatch_computeCurrentTLILightmapDiv2(swigCPtr, this, CRGBA.getCPtr(array), array);
  }

  public CTileElement getTileElement(CUV uv) {
    long cPtr = nel3dJNI.CPatch_getTileElement(swigCPtr, this, CUV.getCPtr(uv), uv);
    return (cPtr == 0) ? null : new CTileElement(cPtr, false);
  }

  public boolean isRenderClipped() {
    return nel3dJNI.CPatch_isRenderClipped(swigCPtr, this);
  }

  public CTessVertex getCornerVertex(long corner) {
    long cPtr = nel3dJNI.CPatch_getCornerVertex(swigCPtr, this, corner);
    return (cPtr == 0) ? null : new CTessVertex(cPtr, false);
  }

  public void deleteVBAndFaceVector() {
    nel3dJNI.CPatch_deleteVBAndFaceVector(swigCPtr, this);
  }

  public void allocateVBAndFaceVector() {
    nel3dJNI.CPatch_allocateVBAndFaceVector(swigCPtr, this);
  }

  public void fillVB() {
    nel3dJNI.CPatch_fillVB(swigCPtr, this);
  }

  public void fillVBIfVisible() {
    nel3dJNI.CPatch_fillVBIfVisible(swigCPtr, this);
  }

  public void deleteVBAndFaceVectorFar1Only() {
    nel3dJNI.CPatch_deleteVBAndFaceVectorFar1Only(swigCPtr, this);
  }

  public void allocateVBAndFaceVectorFar1Only() {
    nel3dJNI.CPatch_allocateVBAndFaceVectorFar1Only(swigCPtr, this);
  }

  public void fillVBFar0Only() {
    nel3dJNI.CPatch_fillVBFar0Only(swigCPtr, this);
  }

  public void fillVBFar1Only() {
    nel3dJNI.CPatch_fillVBFar1Only(swigCPtr, this);
  }

  public void fillVBFarsDLMUvOnly() {
    nel3dJNI.CPatch_fillVBFarsDLMUvOnly(swigCPtr, this);
  }

  public void fillFar0DLMUvOnlyVertexListVB(SWIGTYPE_p_CTessListT_CTessFarVertex_t vertList) {
    nel3dJNI.CPatch_fillFar0DLMUvOnlyVertexListVB(swigCPtr, this, SWIGTYPE_p_CTessListT_CTessFarVertex_t.getCPtr(vertList));
  }

  public void fillFar1DLMUvOnlyVertexListVB(SWIGTYPE_p_CTessListT_CTessFarVertex_t vertList) {
    nel3dJNI.CPatch_fillFar1DLMUvOnlyVertexListVB(swigCPtr, this, SWIGTYPE_p_CTessListT_CTessFarVertex_t.getCPtr(vertList));
  }

  public void debugAllocationMarkIndices(long marker) {
    nel3dJNI.CPatch_debugAllocationMarkIndices(swigCPtr, this, marker);
  }

  public void recreateTessBlockFaceVector(CTessBlock block) {
    nel3dJNI.CPatch_recreateTessBlockFaceVector(swigCPtr, this, CTessBlock.getCPtr(block), block);
  }

  public void deleteAllVegetableIgs() {
    nel3dJNI.CPatch_deleteAllVegetableIgs(swigCPtr, this);
  }

  public void recreateAllVegetableIgs() {
    nel3dJNI.CPatch_recreateAllVegetableIgs(swigCPtr, this);
  }

  public void resetTileLightInfluences() {
    nel3dJNI.CPatch_resetTileLightInfluences(swigCPtr, this);
  }

  public void linkBeforeNearUL(CPatch patchNext) {
    nel3dJNI.CPatch_linkBeforeNearUL(swigCPtr, this, CPatch.getCPtr(patchNext), patchNext);
  }

  public void unlinkNearUL() {
    nel3dJNI.CPatch_unlinkNearUL(swigCPtr, this);
  }

  public CPatch getNextNearUL() {
    long cPtr = nel3dJNI.CPatch_getNextNearUL(swigCPtr, this);
    return (cPtr == 0) ? null : new CPatch(cPtr, false);
  }

  public long getNumNearTessBlocks() {
    return nel3dJNI.CPatch_getNumNearTessBlocks(swigCPtr, this);
  }

  public long updateTessBlockLighting(long numTb) {
    return nel3dJNI.CPatch_updateTessBlockLighting(swigCPtr, this, numTb);
  }

  public void beginDLMLighting() {
    nel3dJNI.CPatch_beginDLMLighting(swigCPtr, this);
  }

  public void processDLMLight(CPatchDLMPointLight pl) {
    nel3dJNI.CPatch_processDLMLight(swigCPtr, this, CPatchDLMPointLight.getCPtr(pl), pl);
  }

  public void endDLMLighting() {
    nel3dJNI.CPatch_endDLMLighting(swigCPtr, this);
  }

  public long getTileMaterialRefCount() {
    return nel3dJNI.CPatch_getTileMaterialRefCount(swigCPtr, this);
  }

  public void setMasterBlock(CTessBlock value) {
    nel3dJNI.CPatch_MasterBlock_set(swigCPtr, this, CTessBlock.getCPtr(value), value);
  }

  public CTessBlock getMasterBlock() {
    return new CTessBlock(nel3dJNI.CPatch_MasterBlock_get(swigCPtr, this), true);
  }

  public CBezierPatch unpackIntoCache() {
    long cPtr = nel3dJNI.CPatch_unpackIntoCache(swigCPtr, this);
    return (cPtr == 0) ? null : new CBezierPatch(cPtr, false);
  }

}
